#include "mygraphicsscene.h"
#include <QtGui>

MyGraphicsScene::MyGraphicsScene() : QGraphicsScene()
{

}

void MyGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    selectedItem = itemAt(event->scenePos());
    if (selectedItem != 0) {
        foreach (QGraphicsItem* item, this->items())
        {
            QGraphicsPolygonItem* pItem = qgraphicsitem_cast<QGraphicsPolygonItem*>(item);
            pItem->setZValue(0);
        }
        selectedItem->setZValue(1);
    }

    QGraphicsScene::mousePressEvent(event);
}


